<template>
	<view class="content">
		<view class="CellBox">

			<up-cell-group :border="false">
				<up-cell :border="false" title="清理缓存" @click="clear">
					<!-- <view slot="value" class="x-f">
						<text style="color: #da1616;font-size: 13px;">{{fileSizeString}}</text>
						<uni-icons v-show="fileSizeString" color="#da1616" type="trash" size="18"></uni-icons>
					</view> -->
				</up-cell>
				<!-- <up-cell :border="false" title="安全设置" @click="ToticketPage" isLink></up-cell> -->
				<up-cell :border="false" title="字体大小" @click="ToChangeSystemSize"></up-cell>
			</up-cell-group>


			<up-cell-group :border="false" style="margin-top: 20px;">
				<up-cell :border="false" title="系统权限" @click="OpenManage" isLink></up-cell>
				<up-cell :border="false" title="系统信息" @click="OpenSystemInfo" isLink></up-cell>
				<up-cell @click="openWebInBrowser(1)" :border="false" title="用户隐私协议" isLink></up-cell>
				<up-cell @click="openWebInBrowser(2)" :border="false" title="用户隐私政策" isLink></up-cell>
			</up-cell-group>


			<!-- #ifndef MP-WEIXIN -->
			<up-cell-group :border="false" style="margin-top: 20px;">
				<up-cell :border="false" title="版本介绍">
					<view slot="value">
						<text style="color: #999;font-size: 13px;">当前版本：{{version}}</text>
					</view>
				</up-cell>
				<up-cell :border="false" title="检查更新" @click="GetUpdate"></up-cell>

			</up-cell-group>
			<!-- #endif -->

			<!-- 注销账号 -->
			<view class="logoutBox">
				<button @click="logout">退出/注销</button>
			</view>

		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue';


	let fileSizeString = ref(0)
	// 清理缓存
	function clear() {
		uni.$utils.layer.confirm("是否清楚本地缓存", (ret) => {
			const { action } = ret;
			if (action == 'confirm') {
				uni.clearStorageSync();
			};
		});
	};

	// 安全设置
	function ToticketPage() {

	};

	// 调整全局字体大小
	function ToChangeSystemSize() {
		uni.navigateTo({
			url: "/st_pages/mine/setting/setSize"
		})
	};

	function OpenManage() {
		uni.openAppAuthorizeSetting({
			success(res) {
				console.log(res)
			},
			fail(err) {
				console.log(err);
			}
		});
	};
	function OpenSystemInfo() { // 获取软件系统信息
		uni.navigateTo({
			url: '/st_pages/mine/setting/systemInfo'
		})
	};
	function openWebInBrowser(type : number) {
		// 获取网页URL
		let url = '';
		let title = "";
		switch (type) {
			case 1: // 用户协议
				url = 'https://api.hzyc.org.cn/download/html/汇创云平台用户协议.html';
				title = "汇创云平台用户协议";
				break;
			case 2: // 隐私政策
				url = 'https://api.hzyc.org.cn/download/html/汇创云平台隐私政策.html';
				title = "汇创云平台隐私政策";
				break;
			default:
				return;
		}

		// #ifdef APP-PLUS
		// 传统APP平台（非鸿蒙）
		try {
			if (plus.runtime.openWeb) {
				plus.runtime.openWeb(url);
			} else if (plus.runtime.openURL) {
				plus.runtime.openURL(url);
			} else {
				console.error('不支持的网页打开方式');
			}
		} catch (e) {
			console.error('打开网页失败:', e);
		}
		// #endif

		// #ifdef MP-WEIXIN || APP-HARMONY
		uni.$utils.navigateToWebView({
			url: url,
			title: title,
			navBgColor: '#51d0d0',
			navTextColor: '#ffffff'
		});
		// #endif


	};

	let version = ref("");
	// 检测更新
	function GetUpdate() {

	};

	// 登出
	function logout() {

	};
</script>

<style lang="scss" scoped>
	/* #ifndef MP-WEIXIN */

	* {
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}

	/* #endif */

	.u-popup {
		flex: initial !important;

	}

	.ModalPopupBox {

		.u-popup__content {
			border-radius: 30rpx !important;
		}
	}

	.content {
		background-color: #f8f8f8;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.CellBox {
			flex: 1;
			// padding-top: 10px;
			// overflow: auto;
			padding: 10px 15px;

			.u-cell-group {
				border-radius: 12px;
				box-shadow: 1px 1px 13px -13px #999;
				overflow: hidden;
				background-color: #fff !important;
			}

			.u-cell {
				// background-color: #fff !important;
				position: relative;
			}

			// 给cell框下方加一根浅的线
			.u-cell::after {
				position: absolute;
				box-sizing: border-box;
				content: ' ';
				pointer-events: none;
				right: 16px;
				bottom: 0;
				left: 16px;
				border-bottom: 1px solid #ebedf0;
				-webkit-transform: scaleY(0.5);
				transform: scaleY(0.5);
			}

			// 去除最后一个cell的下划线
			& .u-cell:last-child::after {
				border-bottom: none !important;
			}
		}

		// 按钮的边框线在这里去除
		uni-button:after {
			border: none !important;
		}

		//  退出登录
		.LoginOutBox {
			width: 100%;
			// text-align: center !important;
			margin-top: 50px;

			button {
				width: 90%;
				margin: 0 auto;
				background-color: #d13c3c;
				border: none !important;
				color: #fff;
			}
		}

		.logoutBox {
			width: 100%;
			margin-top: 50px;

			button {
				width: 90%;
				margin: 0 auto;
				background-color: #f08282;
				border: none !important;
				color: #fff;
			}
		}


		//IP地址 
	}

	.popup-content {
		position: relative;
		display: flex;
		flex-direction: column;
		background-color: #fff;
		width: 86vw;
		max-width: 500px;
		padding: 40rpx 20px 30rpx;
		font-size: 12px;
		border-radius: 4px !important;
		overflow: hidden;

		&_close {
			position: absolute;
			top: 0;
			right: 0;
			width: 28px;
			height: 28px;
			font-weight: 600;
		}

		.title {
			font-size: 16px;
			font-weight: 600;
			text-align: center;
		}

		&_desc {
			margin: 24rpx 0;
			text-align: center;
			color: #999;
		}

		.check {
			zoom: .9;
			font-size: 13px;
			color: #999;
		}

		.btnBox {
			margin-top: 20px;

			.u-button {
				width: 44% !important;
			}
		}
	}
</style>